package cn.edu.hpu.service;

import java.util.List;

import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.hpu.dao.TaskDao;
import cn.edu.hpu.dao.Where;
import cn.edu.hpu.pojo.Message;
import cn.edu.hpu.pojo.Task;
import cn.edu.hpu.util.Pager;


public class TaskService {
	private TaskDao taskDao;
	
	public List<Task> findByTitle(String title){
		return taskDao.findBy("title", title);
	}
	
	
	@Autowired
	public void setTaskDao(TaskDao taskDao) {
		this.taskDao =taskDao;
	}




	public List<Task> findAll(List<Where> wheres) {
		return taskDao.find(wheres);
	}




	public Task findById(String id) {
		Task t = taskDao.get(id);
		if(t!=null){
			return t;
		}else{
			return null;
		}
	}




	public void save(Task task) {
		taskDao.save(task);
		
	}




	public void delete(String id) {
		taskDao.del(id);
		
	}




	public void update(Task t) {
		taskDao.update(t);
	}




	public List<Task> findByProperty(String propertyName,boolean value) {
		
		return taskDao.findBy(propertyName, value) ;
	}
	public long tcount(String userid){
		String hql = "select count(*) from Task where userid=?";
		Object object = taskDao.findUnique(hql, userid);
		return (Long)object;
	}




	
	




	
}
